package com.webchat.admin.controller.mall;

import com.webchat.admin.service.mall.MallShopReviewService;
import com.webchat.common.bean.APIPageResponseBean;
import com.webchat.common.bean.APIResponseBean;
import com.webchat.common.bean.APIResponseBeanUtil;
import com.webchat.common.helper.SessionHelper;
import com.webchat.domain.vo.request.mall.ShopReviewRequestVO;
import com.webchat.domain.vo.response.mall.MallShopReviewResponseVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/admin-service/review/shop")
public class MallShopReviewController {


    @Autowired
    private MallShopReviewService mallShopReviewService;

    /**
     * 审核工单列表
     *
     * @return
     */
    @GetMapping("/page")
    public APIPageResponseBean<MallShopReviewResponseVO> page(
            @RequestParam(value = "shopName", required = false) String shopName,
            @RequestParam(value = "reviewStatus", required = false) Integer reviewStatus,
            @RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNo,
            @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize) {

        return mallShopReviewService.page(shopName, reviewStatus, pageNo, pageSize);
    }


    /**
     * 店铺审核
     *
     * @param shopReviewRequest
     * @return
     */
    @PostMapping("/review")
    public APIResponseBean<Boolean> review(@RequestBody ShopReviewRequestVO shopReviewRequest) {

        shopReviewRequest.setOperator(SessionHelper.getCurrentUserId());
        Boolean res = mallShopReviewService.review(shopReviewRequest);
        return APIResponseBeanUtil.success(res);
    }
}
